package com.woniuxy01;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 作者
 * @create 2025-11-11 9:46
 */
public class Test01 {
    public static void main(String[] args)  {
        test06();
    }

    private static void test06() {
        try{
            int i=0;
            int[] a={1,2,3};
            System.out.println(a[4]);
//            System.out.println(100/i);
//            String str=null;
//            System.out.println(str.length());
            System.out.println("try最后");
        }catch (NullPointerException | ArithmeticException  e){
            System.out.println("发生NullPointerException，处理异常");
        }catch (Exception e){
            System.out.println("发生Exception，处理异常");
        }finally {
            System.out.println("清理资源");
        }
        System.out.println("程序结束");
    }

    private static void test04() {
        try{
            int i=0;
            int[] a={1,2,3};
            System.out.println(a[4]);
//            System.out.println(100/i);
//            String str=null;
//            System.out.println(str.length());
            System.out.println("try最后");
        }catch (NullPointerException e){
            System.out.println("发生NullPointerException，处理异常");
        }catch (ArithmeticException e){
            System.out.println("发生ArithmeticException，处理异常");
        }catch (Exception e){
            System.out.println("发生Exception，处理异常");
        }finally {
            System.out.println("清理资源");
        }
        System.out.println("程序结束");
    }

    private static void test03() {
        try{
            int i=0;
            System.out.println(100/i);
            System.out.println("try最后");
        }catch (Exception e){
            System.out.println("发生异常，处理异常");
        }finally {
            System.out.println("清理资源");
        }
        System.out.println("程序结束");
    }

    private static void test02() throws ParseException {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        String str="2000cccc-1-1";
        Date date = sdf.parse(str);
        System.out.println("转换以后的date:"+date);
    }

    private static void test01() {
        int i=0;
        int[] a={1,2,3};
        String str=null;
//        System.out.println(100/i);
        System.out.println(a[2]);
//        System.out.println(a[3]);
        System.out.println(str.length());
        System.out.println("程序结束");
    }
}
